package common;

import static org.junit.Assert.*;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;

import org.junit.Before;
import org.junit.Test;

import p1000.Calculator;
import p1000.CalculatorImpl;

public class FileIoManagerTest {
	
	private FileIoManager fileIoManager;
	String inputFilePath = "src/addInteger/test/input.txt";
	String outputFilePath = "src/addInteger/test/output.txt";
	
	//환경설정
	@Before
	public void setup(){
		fileIoManager = new FileIoManager(inputFilePath, outputFilePath);		
	}
		
	//scanner 테스트(input file 출력 테스트)
	@Test
	public void scannerTest() {
		/***Given***/
		
		/***When***/
		
		/***Then***/
		String next = fileIoManager.next();
		System.out.println(next);
		assertEquals("1", next);
		
		next = fileIoManager.next();
		System.out.println(next);
		assertEquals("5", next);
	}
		
	//writer 테스트
	@Test
	public void writer_테스트(){
	
		/***Given***/
		
		/***When***/
		fileIoManager.write("3");
		fileIoManager.writeEnd();
		
		/***Then***/
		
		Scanner scanner;
		try {
			scanner = new Scanner(new File(outputFilePath));
			assertEquals("3", scanner.next());
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}